package com.cn.genericity.wildcard;

/**
 * @author hels
 * @version 1.0
 * @date 2022/12/13 17:05
 * 通配符?在泛型中的使用
 */
public class Wildcard<T> {
    public T property;

    public T getProperty() {
        return property;
    }

    public void setProperty(T property) {
        this.property = property;
    }

    public static void func(Wildcard<?> wc) {
        System.out.println(wc.getProperty());
//        wc.setProperty(22);  //不确定类型，因此无法进行修改
    }

    public static void main(String[] args) {
        Wildcard<Integer> wcrd = new Wildcard<>();
        wcrd.setProperty(11);
        func(wcrd);

        Wildcard<String> wcstr = new Wildcard<>();
        wcstr.setProperty("jdjdjjd");
        func(wcstr);
        System.out.println(wcrd);
        System.out.println(wcstr);
    }
}
